package com.ruoyi.biz.letter.util;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists;
import com.ruoyi.biz.category.service.IBizCategoryService;
import com.ruoyi.biz.letter.domain.CategoryBase;
import com.ruoyi.common.core.domain.entity.BizCategory;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.spring.SpringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * @author Fei.Cong
 * @date 2024-08-15 10:16
 */
public class AcceptDeptUtil {

    public static void buildAcceptDept(CategoryBase category) {
        if (CollectionUtil.isNotEmpty(category.getAcceptDepts())) {
            category.setAcceptDept(category.getAcceptDepts().stream().collect(Collectors.joining(",")));
        }
    }

    public static void getAcceptDept(CategoryBase category) {
        if (StrUtil.isNotBlank(category.getAcceptDept())) {
            category.setAcceptDepts(Arrays.stream(category.getAcceptDept().split(",")).collect(Collectors.toList()));
        }
    }

    public static void parseAcceptDept(CategoryBase category) {
        if (StrUtil.isNotBlank(category.getAcceptDept())) {
            category.setAcceptDepts(Arrays.stream(category.getAcceptDept().split(",")).collect(Collectors.toList()));
        }
    }

    public static void handleQueryAcceptDept(CategoryBase category) {
        if (CollectionUtil.isNotEmpty(category.getAcceptDepts())) {
            category.setAcceptDept(category.getAcceptDepts().stream().collect(Collectors.joining(",")));
        }
    }
}
